/******************************************************************************
 *  Author:     Williams, Jacob (williamsj@msoe.edu)
 *  Class:      CE-3910
 *  Instructor: Dr. Barnekow
 *****************************************************************************/
#ifndef _TWI_H_
#define _TWI_H_

#include <avr/io.h>
#include <util/twi.h>

#define Camera_Write_Address 0xC0
#define Camera_Read_Address 0xC1
#define CPU_CLOCK 16e6
#define CAMERA_CLOCK_SPEED 100e3
#define TWI_PRESCALER 0
#define TWI_SPEED (8-(CPU_CLOCK/(2*CAMERA_CLOCK_SPEED)))*1/(4^TWI_PRESCALER)

/**
 * Init function for the TWI interface
 */
void TWIinit(void);

/**
 * This function performs the actions needed by every TWO operation.
 *	1. Clears TWINT
 *	2. Enables TWI system
 *	3. Performs addition commands
 *
 *	Param:		command	- The command to execute
 *	Returns: 	Status of the operation (TWSR)
 */
uint8_t TWIaction(uint8_t command);

/**
 * Reads the contents of the specified register
 *	
 *	Param:		regNumber - The register to retrieve the contents from
 *	Returns: 	The value in the specified register
 */
uint8_t TWIread(uint8_t regNumber);

/**
 * Writes the specified value to the specified register
 *
 *	Param:		regNumber - The register to set the contents of
 *	Param:		value - The value to set the specified value to	
 */
void TWIwrite(uint8_t regNumber, uint8_t value); 

#endif
